package com.xiaouyudeguang.common.entity;

import com.xiaouyudeguang.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Table implements Serializable {

    private String tableName;

    private String comment;

    private List<Column> columns;

    public String getClassName() {
        return StringUtils.captureName(StringUtils.putOffUnderline(this.tableName));
    }

    public String getEntityName() {
        return StringUtils.putOffUnderline(this.tableName.substring(this.tableName.indexOf("_") + 1));
    }

    public String getEntityId() {
        return StringUtils.captureName(getEntityName());
    }
}